<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >

	<h:form id="frm1">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="resourcePanel" header="角色基本信息维护"
			style="margin-bottom:5px"
			footer="角色信息是可以作为权限分配的单元。一种角色可以包含一种或多种权限的组合。">
			<h:panelGrid columns="8" cellspacing="10">								
				<p:outputLabel value="角色ID" />
				<p:inputText  value="#{sysRoleMB.sysRole.id}" required="true" requiredMessage="角色编号必须输入"/>
				<p:outputLabel value="角色名称" />
				<p:inputText value="#{sysRoleMB.sysRole.name}" required="true" requiredMessage="角色名称必须输入"/>
				<p:outputLabel value="角色描述" />
				<p:inputText value="#{sysRoleMB.sysRole.description}" required="true" requiredMessage="角色描述必须输入"/>	
				<p:outputLabel value="角色状态" />
				<p:selectOneMenu value="#{sysRoleMB.sysRole.flag}"
					style="width:125px;" required="true" requiredMessage="角色状态必须输入">
					<f:selectItem  itemLabel="有效"	itemValue="1" />
					<f:selectItem  itemLabel="无效"	itemValue="0" />					
				</p:selectOneMenu>					
			</h:panelGrid>
			<h:panelGrid columns="4" cellspacing="10">			
				<p:commandButton value="新增角色提交"	icon="ui-icon-check" 
					action="#{sysRoleMB.addAction}" update=":tabview:frm1">
				</p:commandButton>	
			</h:panelGrid>
			<p:dataTable id="rdt" var="row" resizableColumns="true" liveResize="true" 
				value="#{sysRoleMB.voSysRole}" editable="true"
				paginator="true" paginatorPosition="bottom" rows="12" 
				style="margin-bottom:10px" >
				
				<p:ajax event="rowEdit" listener="#{sysRoleMB.onRowEdit}"
					update=":tabview:frm1:msgs1" />
				<p:ajax event="rowEditCancel"	listener="#{sysRoleMB.onRowCancel}"
					update=":tabview:frm1:msgs1" />

				<p:column headerText="角色ID" sortBy="#{row.id}">
					<h:outputText value="#{row.id}" />
				</p:column>
				<p:column headerText="角色名称">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.name}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.name}" style="width:100%"
								label="角色名称" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="角色描述">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.description}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.description}" style="width:100%"
								label="角色描述" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="角色状态">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.flag == '1' ? '有效' : (row.flag == '0' ? '无效' : row.flag)}" />
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu value="#{row.flag}" style="width:100%"
								required="true" requiredMessage="角色状态必须输入">
								<f:selectItem  itemLabel="有效"	itemValue="1" />
								<f:selectItem  itemLabel="无效"	itemValue="0" />					
							</p:selectOneMenu>										
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column style="width:32px">
					<p:rowEditor />
				</p:column>
			</p:dataTable>

		</p:panel>
	</h:form>
				
</ui:composition>

